import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'


export default defineConfig({
  plugins: [
    vue(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    proxy: {
      '/seat': {
        target: 'http://localhost:8080', // 后端服务地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/seat/, '/seat'), // 可选：重写路径
      
      },
      '/user': {
        target: 'http://localhost:8080', // 后端服务地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/user/, '/user'), // 可选：重写路径
      },
      '/order': {
        target: 'http://localhost:8080', // 后端服务地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/order/, '/order'), // 可选：重写路径
      },
      '/selectorder':{
        target: 'http://localhost:8080', // 后端服务地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/selectorder/, '/selectorder'), // 可选：重写路径
      },
      '/selecttrain':{
        target: 'http://localhost:8080', // 后端服务地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/selecttrain/, '/selecttrain'), // 可选：重写路径
      },
      '/deletetrainorder':{
        target: 'http://localhost:8080', // 后端服务地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/deletetrainorder/, '/deletetrainorder'), // 可选：重写路径
      },
      '/news':{
        target: 'http://localhost:8080', // 后端服务地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/news/, '/news'), // 可选：重写路径
      },
      '/changeorder':{
        target: 'http://localhost:8080', // 后端服务地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/changeorder/, '/changeorder'), // 可选：重写路径
      },
      '/deletetrain':{
        target: 'http://localhost:8080', // 后端服务地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/deletetrain/, '/deletetrain'), // 可选：重写路径
      },
      '/updatetrain':{
       target: 'http://localhost:8080', // 后端服务地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/updatetrain/, '/updatetrain'), // 可选：重写路径
      },
      'updateuser':{
        target: 'http://localhost:8080', // 后端服务地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/updateuser/, '/updateuser'), // 可选：重写路径
      },
      '/register': { // 新增注册接口代理
        target: 'http://localhost:8080',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/register/, '/register')
      }
    }
  }
})
